<template>
  <div>
    <Modal v-model="modal.add" title="添加" :mask-closable="false" @on-visible-change="changeModalVisibleResetForm('addForm', $event)"
      width="1020">
      <Form ref="addForm" :model="form" :label-width="120" :rules="validateRules">
        <Row>
          <i-col span="12">
            <FormItem label="用户编号" prop="userId">
              <InputNumber v-model="form.userId" placeholder="请输入用户编号" style="width: 100%;" />
            </FormItem>
          </i-col>
          <i-col span="12">
            <FormItem label="真实姓名" prop="realName">
              <Input v-model="form.realName" placeholder="请输入真实姓名" clearable />
            </FormItem>
          </i-col>
          <i-col span="12">
            <FormItem label="卡号" prop="cardNumber">
              <Input v-model="form.cardNumber" placeholder="请输入卡号" clearable />
            </FormItem>
          </i-col>
          <!-- <i-col span="12">
            <FormItem label="图片" prop="cardImg">
              <Input v-model="form.cardImg" placeholder="请输入图片" clearable />
            </FormItem>
          </i-col> -->
         <!-- <i-col span="12">
            <FormItem label="认证类型 1、一卡通2、学生证" prop="type">
              <InputNumber v-model="form.type" placeholder="请输入认证类型 1、一卡通2、学生证" style="width: 100%;" />
            </FormItem>
          </i-col> -->
          <i-col span="12">
            <FormItem label="审核状态" prop="checkStatus">
              <InputNumber v-model="form.checkStatus" placeholder="请输入审核状态 1、认证中 2" style="width: 100%;" />
            </FormItem>
          </i-col>
          <i-col span="12">
            <FormItem label="审核描述" prop="checkDes">
              <Input v-model="form.checkDes" placeholder="请输入审核描述" clearable />
            </FormItem>
          </i-col>

        </Row>

      </Form>
      <div slot="footer">
        <Button type="text" size="large" @click="resetFormCancelModal('addForm', 'add')">取消</Button>
        <Button type="primary" size="large" @click="add" :loading="loading.add">添加</Button>
      </div>
    </Modal>
    <Modal v-model="modal.edit" title="修改" :mask-closable="false" @on-visible-change="changeModalVisibleResetForm('editForm', $event)"
      width="1020">
      <Form ref="editForm" :model="form" :label-width="120" :rules="validateRules">
        <Row>
          <i-col span="12">
            <FormItem label="用户编号" prop="userId">
              <InputNumber v-model="form.userId" placeholder="请输入用户编号" style="width: 100%;" />
            </FormItem>
          </i-col>
          <i-col span="12">
            <FormItem label="真实姓名" prop="realName">
              <Input v-model="form.realName" placeholder="请输入真实姓名" clearable />
            </FormItem>
          </i-col>
          <i-col span="12">
            <FormItem label="身份证" prop="cardNumber">
              <Input v-model="form.cardNumber" placeholder="请输入卡号" clearable />
            </FormItem>
          </i-col>
         <!-- <i-col span="12">
            <FormItem label="图片" prop="cardImg">
              <Input v-model="form.cardImg" placeholder="请输入图片" clearable />
            </FormItem>
          </i-col> -->
         <!-- <i-col span="12">
            <FormItem label="认证类型 1、一卡通2、学生证" prop="type">
              <InputNumber v-model="form.type" placeholder="请输入认证类型 1、一卡通2、学生证" style="width: 100%;" />
            </FormItem>
          </i-col> -->
          <i-col span="12">
            <FormItem label="审核状态(1认证中 2认证失败 3已认证)" prop="checkStatus">
              <InputNumber v-model="form.checkStatus" placeholder="请输入审核状态" style="width: 100%;" />
            </FormItem>
          </i-col>
          <i-col span="12">
            <FormItem label="审核描述" prop="checkDes">
              <Input v-model="form.checkDes" placeholder="请输入审核描述" clearable />
            </FormItem>
          </i-col>

        </Row>

      </Form>
      <div slot="footer">
        <Button type="text" size="large" @click="resetFormCancelModal('editForm', 'edit')">取消</Button>
        <Button type="primary" size="large" @click="edit" :loading="loading.edit">修改</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
  import * as utils from '@/api/utils-v2'
  import * as ResponseStatus from '@/api/response-status'
  export default {
    name: 'UserCertificationAddEdit',
    data() {
      return {
        modal: {
          add: false,
          edit: false
        },
        loading: {
          add: false,
          edit: false
        },
        urls: {
          addUrl: '/user-certification/admin/save',
          batchAddUrl: '/user-certification/admin/batch-save',
          editUrl: '/user-certification/admin/update',
          batchEditUrl: '/user-certification/admin/batch-update'
        },
        form: {
          userId: null,
          realName: null,
          cardNumber: null,
          cardImg: null,
          type: null,
          checkStatus: null,
          checkDes: null,

        },
        validateRules: {
          userId: [{
            type: 'integer',
            required: true,
            message: '此项为必须项',
            trigger: 'blur, change'
          }],
          realName: [{
              type: 'string',
              required: true,
              message: '此项为必须项',
              trigger: 'blur'
            },
            {
              type: 'string',
              min: 1,
              max: 10,
              message: '必须1-10个字符',
              trigger: 'blur'
            }
          ],
          cardNumber: [{
            type: 'string',
            min: 1,
            max: 100,
            message: '必须1-100个字符',
            trigger: 'blur'
          }],
          cardImg: [{
            type: 'string',
            min: 1,
            max: 255,
            message: '必须1-255个字符',
            trigger: 'blur'
          }],
          checkDes: [{
            type: 'string',
            min: 1,
            max: 255,
            message: '必须1-255个字符',
            trigger: 'blur'
          }],

        },
        dataDictCodes: [],
        dataDictItems: {},
      }
    },
    computed: {},
    mounted() {},
    methods: {
      changeModalVisibleResetForm(formRef, visible) {
        if (!visible) {
          this.$refs[formRef].resetFields()
          this.form.id = null
        }
      },
      resetFormCancelModal(formRef, modal) {
        this.modal[modal] = false
        this.$refs[formRef].resetFields()
        this.form.id = null
      },
      add() {
        this.$emit('add')
      },
      edit() {
        this.$emit('edit')
      }
    }
  }
</script>

<style>
</style>
